

package com.liulishuo.filedownloader.i;


import com.liulishuo.filedownloader.message.MessageSnapshot;
import ohos.rpc.IRemoteObject;
import ohos.rpc.RemoteException;
import ohos.rpc.MessageParcel;
import ohos.rpc.MessageOption;

public class FileDownloadIPCCallbackProxy implements IFileDownloadIPCCallback {
    private static final String DESCRIPTOR = "com.liulishuo.filedownloader.i.IFileDownloadIPCCallback";

    private static final int COMMAND_CALLBACK = IRemoteObject.MIN_TRANSACTION_ID + 0;
    private static final String TAG = FileDownloadIPCCallbackProxy.class.getSimpleName();

    private final IRemoteObject remote;
    private static final int ERR_OK = 0;

    public FileDownloadIPCCallbackProxy(
        /* [in] */ IRemoteObject remote) {
        this.remote = remote;
    }

    @Override
    public IRemoteObject asObject() {
        return remote;
    }

    @Override
    public void callback(
        /* [in] */ MessageSnapshot snapshot) throws RemoteException {
        MessageParcel data = MessageParcel.obtain();
        MessageParcel reply = MessageParcel.obtain();
        MessageOption option = new MessageOption(MessageOption.TF_SYNC);


        data.writeInterfaceToken(DESCRIPTOR);
        data.writeSequenceable(snapshot);

        try {
            remote.sendRequest(COMMAND_CALLBACK, data, reply, option);
            reply.readException();
        } finally {
            data.reclaim();
            reply.reclaim();
        }
    }
};

